import Item from 'antd/lib/list/Item';
import { getDataList, getDormitoryList, xgshopdata, importDate, zhirishang, xougaipingji, remove,tihuan } from '../../api/Dormitory'
const dormitoryActions = {
  iszrs(val) {
    console.log(val);
    return async (dispatch) => {
      dispatch({
        type: 'zrs',
        payload: val,
      });
    }
  },
  getlist(val) {
    return async (dispatch) => {
      let payload = await getDataList(val).then((res) => {
        return res.data;
      });
      console.log(payload);
      dispatch({
        type: 'getlist',
        payload,
      });
    };
  },
  getDormitoryList() {
    return async (dispatch) => {
      let payload = await getDormitoryList().then((res) => {
        return res.data.data;
      });
      dispatch({
        type: 'DormitoryList',
        payload,
      });
    }
  },
  xgsHopdata(val) {
    let obj = {
      keyPath: val.keyPath[0],
      keyPath1: val.keyPath[1],
      id: val.id,
      val: val.ite,
      inset: val.inset,
    }
    return async (dispatch) => {
      let payload = await xgshopdata(obj).then((res) => {
        return res.data
      })
      console.log(payload)
      dispatch({
        type: 'xgshopdata',
        payload,
      });
    }
  },
  remove(val) {
    let obj = {
      keyPath: val.keyPath[0],
      keyPath1: val.keyPath[1],
      id: val.id,
      val: val.ite,
      inset: val.inset,
    }
    return async (dispatch) => {
      let payload = await remove(obj).then((res) => {
        return res.data
      })
      console.log(payload)
      dispatch({
        type: 'remove',
        payload,
      });
    }
  },
  tihuan(val) {
    let obj = {
      keyPath: val.keyPath[0],
      keyPath1: val.keyPath[1],
      id: val.id,
      val: val.ite,
      inset: val.inset,
    }
    return async (dispatch) => {
      let payload = await tihuan(obj).then((res) => {
        return res.data
      })
      console.log(payload)
      dispatch({
        type: 'tihuan',
        payload,
      });
    }
  },
  
  zhirishang(val) {
    let obj = {
      keyPath: val.keyPath[0],
      keyPath1: val.keyPath[1],
      val: val.item,
      id: val.id,
      inset: val.inset
    }
    return async (dispatch) => {
      let payload = await zhirishang(obj).then((res) => {
        return res.data;
      });
      console.log(payload);
      dispatch({
        type: 'zhirishang',
        payload,
      });
    };
  },
  importDate(obj) {
    return async (dispatch) => {
      let payload = await importDate(obj).then((res) => {
        return res.data.data;
      });
      dispatch({
        type: "DormitoryList",
        payload,
      });
    }
  },
  xougaipingji(val) {
    let obj = {
      e: val.e,
      val: val.item
    }
    return async (dispatch) => {
      let payload = await xougaipingji(obj).then((res) => {
        return res.data
      })
      dispatch({
        type: "xougaipingji",
        payload,
      });
    }
  }
}
export default dormitoryActions;